// 引入 request 方法，假设 request 方法已经定义在某个工具文件中
import request from '/@/utils/request';
import { AlipayPreCreateInput,AlipayTradePagePayInput } from '../models';

// 定义 API 路径枚举
enum Api {
    AlipayPreCreate = '/alipay/alipayPreCreate',
    AlipayTradePagePay = '/alipay/alipayTradePagePay',
    GetAuthInfo = '/alipay/getAuthInfo',
    Notify = '/alipay/notify',
}

// 定义 API 方法
/**
 * 交易预创建
 * @param body 请求体
 */
export const apiAlipayAlipayPreCreatePost = (body: AlipayPreCreateInput) =>
    request({
        url: Api.AlipayPreCreate,
        method: 'post',
        data: body,
    });

/**
 * 统一收单下单并支付页面接口
 * @param body 请求体
 */
export const apiAlipayAlipayTradePagePayPost = (body: AlipayTradePagePayInput) =>
    request({
        url: Api.AlipayTradePagePay,
        method: 'post',
        data: body,
    });

/**
 * 获取授权信息
 * @param userId 用户Id
 * @param authCode 授权码
 */
export const apiAlipayGetAuthInfoGet = (userId?: string, authCode?: string) =>
    request({
        url: Api.GetAuthInfo,
        method: 'get',
        params: {
            UserId: userId,
            AuthCode: authCode,
        },
    });

/**
 * 支付回调
 */
export const apiAlipayNotifyPost = () =>
    request({
        url: Api.Notify,
        method: 'post',
    });